function [cframes,cdescr]=remove_duplication(tframes,tdescr)
% function [cframes,cdescr]=remove_duplication(tframes,tdescr)
%   remove SPs that are too close to each other, this is a design problem
%   and we just write a gross sample code here for testing purpuse

idx=true(1,size(tframes,2));
for ii=1:size(tframes,2)
    if(~idx(ii))% ii is already deleted
        continue;
    end
    xyii=tframes(1:2,ii);
    rii=tframes(3,ii);
    sigii=tframes(4,ii);
    for jj=ii+1:size(tframes,2)
        if(~idx(jj))%jj is already deleted
            continue;
        end
        xyjj=tframes(1:2,jj);
        rjj=tframes(3,jj);
        sigjj=tframes(4,jj);
        ds=xyii-xyjj;
        ds=sqrt(sum(ds.^2));
        if(ds<rii*0.8||ds<rjj*0.8)%duplicates! decide which one to go
            if(sigii>sigjj)
                idx(jj)=false;
            else
                idx(ii)=false;
            end
        end
    end
end
cframes=tframes(:,idx);
cdescr=tdescr(:,idx);
end